package com.huaxindata.im.main.contactview.friend;

import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.huaxin.common.view.avatarimageview.AvatarImageView;
import com.huaxin.common.view.avatarimageview.HxAvatarImageGlide;
import com.huaxindata.im.R;
import com.huaxindata.im.main.manager.ContactManager;
import com.huaxindata.im.model.contact.Contact;

/**
 * @author songxf
 * @date 2017/11/7
 * @Desc 添加好友adapter
 * Copyright HUAXIN DATA. All rights reserved.
 */
public class HxSearchContactAdapter extends BaseQuickAdapter<Contact, BaseViewHolder> {
    private static int mType;

    public HxSearchContactAdapter() {
        super(R.layout.item_search_contact);
    }

    public void setSelectType(int type) {
        this.mType = type;
    }

    @Override
    protected void convert(BaseViewHolder helper, Contact item) {
        AvatarImageView mHeaderImg = helper.getView(R.id.header_img);
        HxAvatarImageGlide instance = HxAvatarImageGlide.getInstance();
        instance.setHeadImage(mContext, item.getIcon(), item.getNickName(), mHeaderImg);

        helper.setText(R.id.name_tv, item.getNickName());

        TextView mFriendFlagTv = helper.getView(R.id.friend_flag_tv);
        //判断是否是好友
        if (ContactManager.isFriend(item.getClientId())) {
            mFriendFlagTv.setVisibility(View.VISIBLE);
        } else {
            mFriendFlagTv.setVisibility(View.GONE);
        }

       /* if (item.getLatLng() != null) {
            String distanceStr = HxDistanceUtil.getDistanceStr(BaseApp.getLatLng(),
                    item.getLatLng());
            String duty = item.getDuty();
            if (!TextUtils.isEmpty(duty)) {
                distanceStr = duty + "   " + distanceStr + "km";
            }
            helper.setText(R.id.des_tv, distanceStr);
        } else {
            helper.setText(R.id.des_tv, item.getPhone());
        }*/

        helper.setText(R.id.des_tv, item.getPhone());



    }
}
